home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 3 / Gekikoh Dennoh Club Vol. 3 (Japan).7z / Gekikoh Dennoh Club Vol. 3 (Japan) (Track 1).bin / games / rifler / c / src.lzh / Rifler.c < prev    next >
Text File  |  1998-01-04  |  6KB  |  285 lines

  1. /*                                        
  2.         Rifle the ancient remains
  3.             「古跡盗掘」
  4.             Rifler.c    main routine
  5.     
  6.     Rifler.h    header file.
  7.     Rifler_v.c    v_sync,sp,score,load_map,joystick etc.
  8.     Rifler_s.c    various routines(load area,change map data,etc.)
  9.     Rifler_m.c    monster & effector etc.
  10.     Rifler_p.c    player's & shot's movements & use item.
  11.     Rifler_o.c    check a overlap & calc. hp,sc,hs etc.
  12.     Rifler_d.c    domonstration etc.
  13.     
  14.                         BY SJOM
  15.                                         
  16. */
  17.  
  18. #include <unistd.h>
  19. #define first
  20. #include "Rifler.h"
  21.  
  22.  
  23. char no_option_msg[]=
  24. "Rifle the ancient remains
  25.     「古跡盗掘」        version.1.04
  26.                 BY SJOM
  27.     実行方法
  28.     filer.x filename.???
  29.     filenameは、面データの入ったファイルで、拡張子は、
  30.     何でもいいです。";
  31.  
  32.  
  33.  
  34. #define gameover    1
  35. #define ending        0
  36.  
  37. static void
  38. main_abort(void)
  39. {
  40.     _iocs_vdispst(0,0,1);
  41.     _iocs_crtcras(0,0);
  42. /*    _iocs_hsyncst(0);    */
  43. }
  44.  
  45.  
  46. static void
  47. initialize(void)
  48. {
  49.     contrast(0);            /* set constrast to 0 */
  50.     wait_time(100);            /* one second wait */
  51.     _iocs_crtmod(14);        /* set crt mode to 31kHz 256*256 */
  52.     _iocs_g_clr_on();        /* initialize graphic vram */
  53.     _iocs_sp_init();        /* initialize sprite */
  54.     _iocs_bgctrlst(0,1,1);        /* bg0 - bgtext1 */
  55.     _iocs_bgtextcl(1,0);        /* clear bg0(bgtext1) */
  56.     _iocs_b_clr_al();        /* clear text vram */
  57.     init_sounds();            /* check zmusic & load se & bgm */
  58.     if (zmusic==0) {
  59.         puts("無音モードになります。");
  60.         wait_time(800);
  61.         _iocs_b_clr_al();
  62.     };
  63.     PAL_load("Rifler.PAL");            /* load sprite palette data */
  64.     PCG_load("Rifler_s.SP");        /* load basic sprite PCG data */
  65.     player_PCG_load("Rifler_p.SP");        /* allocate player's sprite PCG data */
  66.     gbg_PCG_load("Rifler.GBG");        /* allocate gbg data */
  67.     _iocs_b_curoff();        /* cursol off */
  68.     init_sp_data();
  69.     _iocs_sp_on();
  70.     now_map=malloc_check(32*32);
  71. }
  72.  
  73.  
  74. static void
  75. put_logotype(void)
  76. {
  77.     contrast(0);
  78.     wait_time(200);
  79.     contrast(15);
  80. /*    print_bg(12,16,sjom_msg);*/
  81.     print_sjom_logo();
  82.     wait_time(300);        /* 3 seconds wait */
  83.     contrast(0);
  84.     wait_time(200);
  85.     print_bg(12,16,BG_clr_16);
  86. }
  87.  
  88.  
  89. static void
  90. demo(void)
  91. {
  92.     while (true)
  93.         if (title()==yes) {
  94.             demo_gbg_set();
  95.             if (demo_play()) {
  96.                 contrast(0);
  97.                 wait_time(200);
  98.                 break;
  99.             };
  100.         } else
  101.             break;
  102. }
  103.  
  104.  
  105. static void
  106. game_clear_loop(void)
  107. {
  108.     int loop;
  109.     bgm(game_clear_bgm);
  110.     for (loop=0;loop<60*3;loop++) {
  111.         switch (loop & 3) {
  112.         case 0:
  113.             game_player.dir=down;
  114.             break;
  115.         case 1:
  116.             game_player.dir=right;
  117.             break;
  118.         case 2:
  119.             game_player.dir=up;
  120.             break;
  121.         default:
  122.             game_player.dir=left;
  123.         };
  124.         player_sp_set(&game_player,character);
  125.         sort_out_sprite();
  126.         sprite_sw=on;
  127.         wait_vsync();
  128.         score_calc();
  129.         hp_calc();
  130.         wait_vsync();
  131.         score_calc();
  132.         hp_calc();
  133.         escape();
  134.         if (loop==60*2)
  135.             contrast(0);
  136.     };
  137.     for (;;) {
  138.         score_calc();
  139.         hp_calc();
  140.         if ((addsub_sc==0) & (addsub_hp==0))
  141.             break;
  142.     };
  143. }
  144.  
  145.  
  146.  
  147.  
  148. int
  149. game_main(void)
  150. {
  151.     int loop;
  152.     area_no=0;
  153.     now_area_data=area_data;
  154.     print_bg(0,0,hp_sc_hs);
  155.     print_bg(0,31,item_msg);
  156.     game_player.hp=4;
  157.     addsub_hp=affinity[character].first_hp*4-4;
  158.     score=addsub_sc=mattock=elixir=large_shield=small_shield=0;
  159.     print_number(hi_sc_x,hi_sc_y,hi_score,100000);
  160.     for (;;) {
  161.         init_sp_data();
  162.         gold_no=now_area_data->gold_no;
  163.         wflash_sw=off;
  164.         flash.x=flash.y=0;
  165. /*
  166.         if (gold_no==not_ready) {
  167.             map_convert(now_area_data);
  168.             gold_no=now_area_data->gold_no;
  169.         };
  170. */
  171.         get_true_key=no;
  172.         game_clear=no;
  173.         game_start_time=_iocs_ontime();
  174.         game_limit_time=game_start_time+120*100+gold_no*10*100;
  175.         if (game_limit_time>8639999)
  176.             game_limit_time-=8640000;
  177.         print_bg(key_x,item_y," ");
  178.         print_map();        /* init. anything & display */
  179.         scroll_sw=on;
  180.         bgm(game_bgm);
  181.         contrast(15);
  182.         for (loop=0;loop<6*5;loop++) {    /* it equals wait_time(50); */
  183.             wait_vsync();
  184.         };
  185.         for (;;)  {
  186.             move_player();        /* a movement of player */
  187.             use_mattock();        /* use mattock  */
  188. #ifdef debug
  189.     if (_iocs_bitsns(5) & 4) {    /*key z 押されたか?*/
  190.         character++;
  191.         if (character<0)
  192.             character=4;
  193.         if (character>=5)
  194.             character=0;
  195.         wait_time(40);
  196.         wait_vsync();
  197.         exchange_player_PCG(character);
  198.     };
  199. #endif
  200.             move_shot();        /* a movement of shot */
  201.             move_monster();        /* a movement of monsters */
  202.             move_effector();    /* a movement of effectors */
  203.             
  204.             take_item();        /* take items */
  205.             overlap_characters();    /* check a overlap */
  206.             
  207.             way_flash();
  208.             
  209.             score_calc();
  210.             hp_calc();
  211.             
  212.             sort_out_sprite();
  213.             if (scroll_mode)
  214.                 scroll_sw=on;
  215.             else
  216.                 sprite_sw=on;
  217.             wait_vsync();
  218.             if (game_clear)
  219.                 break;
  220.             if (game_player.hp==0) {
  221.                 /*game_clear=no;*/
  222.                 break;
  223.             };
  224.             escape();
  225.             pause_space();
  226.             time_limit_check();
  227.         };
  228.         if (game_clear)        /* game clear */
  229.             game_clear_loop();
  230.         else {
  231.             /* game_over sub */
  232.             prt_game_over();
  233.             return gameover;
  234.         };
  235.         now_area_data=now_area_data->next;
  236.         if (now_area_data==NULL) {
  237.             init_sp_data();
  238.             endings();
  239.             return ending;
  240.         };
  241.         area_no++;
  242.     };
  243. }
  244.  
  245.  
  246.  
  247. #define first_hisc 6800
  248.  
  249.  
  250. int
  251. main(int argc,char **argv)
  252. {
  253.     /*debug_mode=off;*/
  254.     if (argc!=2) {
  255.         puts(no_option_msg);
  256.         exit(noerror);
  257.     };
  258. /*
  259.     if (argc<2) {
  260.         puts(no_option_msg);
  261.         exit(noerror);
  262.     } else if (argc>=3)
  263.         *//*debug_mode=on;*//*
  264.         ligten_a_load=true;
  265. */
  266.     onexit((onexit_t)main_abort);
  267.     _iocs_vdispst(&vsync_routine,0,1);        /* v_blank rewriting on */
  268.     load_area(argv[1]);
  269.     initialize();
  270.     hi_score=first_hisc;
  271.     put_logotype();
  272.     for (;;) {
  273.         scroll_x=scroll_y=0;
  274.         scroll_sw=on;
  275.         wait_vsync();
  276.         demo();
  277.         character=select_player();
  278.         if (game_main()==ending)
  279.             put_logotype();
  280.     };
  281. }
  282.  
  283.  
  284.  
  285.